<script setup lang='ts'>
interface ITabItem extends IBaseTabItem {
  path: string
  icon: string
  iconActColor: string
}

defineOptions({ name: 'AppSportsPagesTab' })
const props = defineProps<{ currentPage: string }>()

const { t } = useI18n()

const tabList = [
  { value: 'home', label: t('recommend'), path: '/', icon: 'sports-rec', iconActColor: '#FF9820' },
  { value: 'event-builder', label: t('spt_schedule_filter'), path: '/event-builder', icon: 'uni-cal', iconActColor: '#BC4EFF' },
  { value: 'bets-feed', label: t('spt_bet_order_follow_up'), path: '/bets-feed', icon: 'uni-rows', iconActColor: '#67B6FF' },
]

function onItemClick(tab: ITabItem) {
  if (tab.value === props.currentPage)
    return

  i18nNavigateTo(`/sports?bt-path=${encodeURIComponent(tab.path)}`)
}
</script>

<template>
  <BaseSportsTab :current="currentPage" :list="tabList" @item-click="onItemClick">
    <template #item="{ data: { item, active } }">
      <div class="item" :class="{ active }">
        <div class="mr-[8px] flex items-center text-[16px]"
          :style="[active ? `--tg-base-icon-color:${item.iconActColor};` : '']">
          <BaseIcon :name="item.icon" />
        </div>
        {{ item.label }}
      </div>
    </template>
  </BaseSportsTab>
</template>

<style lang='scss' scoped>
.item {
  display: flex;
  align-items: center;
  background: var(--color-bg-black-3);
  padding: 0 12px;
  border-radius: 18px;
  text-transform: uppercase;
  font-weight: 700;

  &.active {
    color: var(--color-text-white-0);
    background: var(--color-bg-black-5);
  }

  @media (hover: hover) and (pointer: fine) {
    &:not(.active):hover {
      cursor: pointer;
      background: var(--color-bg-black-5);
      transition: all 0.3s;
    }
  }
}
</style>
